home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / earthlink / nscomm / java40.jar / java / awt / Component.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-11-03  |  8.1 KB  |  563 lines

  1. package java.awt;
  2.  
  3. import java.awt.image.ColorModel;
  4. import java.awt.image.ImageObserver;
  5. import java.awt.image.ImageProducer;
  6. import java.awt.peer.ComponentPeer;
  7. import java.io.PrintStream;
  8. import java.io.Serializable;
  9.  
  10. public abstract class Component implements ImageObserver, Serializable {
  11.    transient ComponentPeer peer;
  12.    transient Container parent;
  13.    // $FF: renamed from: x int
  14.    int field_0;
  15.    // $FF: renamed from: y int
  16.    int field_1;
  17.    int width;
  18.    int height;
  19.    Color foreground;
  20.    Color background;
  21.    Font font;
  22.    boolean visible = true;
  23.    boolean enabled = true;
  24.    boolean valid = false;
  25.    String name;
  26.    static final Object LOCK = new Object();
  27.  
  28.    Component() {
  29.    }
  30.  
  31.    public Container getParent() {
  32.       return this.parent;
  33.    }
  34.  
  35.    public ComponentPeer getPeer() {
  36.       return this.peer;
  37.    }
  38.  
  39.    public Toolkit getToolkit() {
  40.       ComponentPeer var1 = this.peer;
  41.       if (var1 != null) {
  42.          return var1.getToolkit();
  43.       } else {
  44.          Container var2 = this.parent;
  45.          return var2 != null ? ((Component)var2).getToolkit() : Toolkit.getDefaultToolkit();
  46.       }
  47.    }
  48.  
  49.    public boolean isValid() {
  50.       return this.peer != null && this.valid;
  51.    }
  52.  
  53.    public boolean isVisible() {
  54.       return this.visible;
  55.    }
  56.  
  57.    public boolean isShowing() {
  58.       if (this.visible && this.peer != null) {
  59.          Container var1 = this.parent;
  60.          return var1 == null || ((Component)var1).isShowing();
  61.       } else {
  62.          return false;
  63.       }
  64.    }
  65.  
  66.    public boolean isEnabled() {
  67.       return this.enabled;
  68.    }
  69.  
  70.    public Point location() {
  71.       return new Point(this.field_0, this.field_1);
  72.    }
  73.  
  74.    public Dimension size() {
  75.       return new Dimension(this.width, this.height);
  76.    }
  77.  
  78.    public Rectangle bounds() {
  79.       return new Rectangle(this.field_0, this.field_1, this.width, this.height);
  80.    }
  81.  
  82.    public synchronized void enable() {
  83.       if (!this.enabled) {
  84.          this.enabled = true;
  85.          if (this.peer != null) {
  86.             this.peer.enable();
  87.          }
  88.       }
  89.  
  90.    }
  91.  
  92.    public void enable(boolean var1) {
  93.       if (var1) {
  94.          this.enable();
  95.       } else {
  96.          this.disable();
  97.       }
  98.    }
  99.  
  100.    public synchronized void disable() {
  101.       if (this.enabled) {
  102.          this.enabled = false;
  103.          if (this.peer != null) {
  104.             this.peer.disable();
  105.          }
  106.       }
  107.  
  108.    }
  109.  
  110.    public void setVisible(boolean var1) {
  111.       this.show(var1);
  112.    }
  113.  
  114.    public synchronized void show() {
  115.       if (!this.visible) {
  116.          this.visible = true;
  117.          if (this.peer != null) {
  118.             this.peer.show();
  119.             if (this.parent != null) {
  120.                this.parent.invalidate();
  121.             }
  122.          }
  123.       }
  124.  
  125.    }
  126.  
  127.    public void show(boolean var1) {
  128.       if (var1) {
  129.          this.show();
  130.       } else {
  131.          this.hide();
  132.       }
  133.    }
  134.  
  135.    public synchronized void hide() {
  136.       if (this.visible) {
  137.          this.visible = false;
  138.          if (this.peer != null) {
  139.             this.peer.hide();
  140.             if (this.parent != null) {
  141.                this.parent.invalidate();
  142.             }
  143.          }
  144.       }
  145.  
  146.    }
  147.  
  148.    public Color getForeground() {
  149.       Color var1 = this.foreground;
  150.       if (var1 != null) {
  151.          return var1;
  152.       } else {
  153.          Container var2 = this.parent;
  154.          return var2 != null ? ((Component)var2).getForeground() : null;
  155.       }
  156.    }
  157.  
  158.    public synchronized void setForeground(Color var1) {
  159.       this.foreground = var1;
  160.       if (this.peer != null) {
  161.          var1 = this.getForeground();
  162.          if (var1 != null) {
  163.             this.peer.setForeground(var1);
  164.          }
  165.       }
  166.  
  167.    }
  168.  
  169.    public Color getBackground() {
  170.       Color var1 = this.background;
  171.       if (var1 != null) {
  172.          return var1;
  173.       } else {
  174.          Container var2 = this.parent;
  175.          return var2 != null ? ((Component)var2).getBackground() : null;
  176.       }
  177.    }
  178.  
  179.    public synchronized void setBackground(Color var1) {
  180.       this.background = var1;
  181.       if (this.peer != null) {
  182.          var1 = this.getBackground();
  183.          if (var1 != null) {
  184.             this.peer.setBackground(var1);
  185.          }
  186.       }
  187.  
  188.    }
  189.  
  190.    public Font getFont() {
  191.       Font var1 = this.font;
  192.       if (var1 != null) {
  193.          return var1;
  194.       } else {
  195.          Container var2 = this.parent;
  196.          return var2 != null ? ((Component)var2).getFont() : null;
  197.       }
  198.    }
  199.  
  200.    public synchronized void setFont(Font var1) {
  201.       this.font = var1;
  202.       if (this.peer != null) {
  203.          var1 = this.getFont();
  204.          if (var1 != null) {
  205.             this.peer.setFont(var1);
  206.          }
  207.       }
  208.  
  209.    }
  210.  
  211.    public synchronized ColorModel getColorModel() {
  212.       return this.peer == null ? this.getToolkit().getColorModel() : this.peer.getColorModel();
  213.    }
  214.  
  215.    public void move(int var1, int var2) {
  216.       this.reshape(var1, var2, this.width, this.height);
  217.    }
  218.  
  219.    public void resize(int var1, int var2) {
  220.       this.reshape(this.field_0, this.field_1, var1, var2);
  221.    }
  222.  
  223.    public void resize(Dimension var1) {
  224.       this.reshape(this.field_0, this.field_1, var1.width, var1.height);
  225.    }
  226.  
  227.    public synchronized void reshape(int var1, int var2, int var3, int var4) {
  228.       boolean var5 = this.width != var3 || this.height != var4;
  229.       if (var5 || this.field_0 != var1 || this.field_1 != var2) {
  230.          this.field_0 = var1;
  231.          this.field_1 = var2;
  232.          this.width = var3;
  233.          this.height = var4;
  234.          if (this.peer != null) {
  235.             this.peer.reshape(var1, var2, var3, var4);
  236.             if (var5) {
  237.                this.invalidate();
  238.             }
  239.  
  240.             if (this.parent != null) {
  241.                this.parent.invalidate();
  242.             }
  243.          }
  244.       }
  245.  
  246.    }
  247.  
  248.    public Dimension preferredSize() {
  249.       ComponentPeer var1 = this.peer;
  250.       return var1 != null ? var1.preferredSize() : this.minimumSize();
  251.    }
  252.  
  253.    public Dimension minimumSize() {
  254.       ComponentPeer var1 = this.peer;
  255.       return var1 != null ? var1.minimumSize() : this.size();
  256.    }
  257.  
  258.    public void layout() {
  259.    }
  260.  
  261.    public void validate() {
  262.       while(!this.valid && this.peer != null) {
  263.          this.layout();
  264.          this.valid = true;
  265.       }
  266.  
  267.    }
  268.  
  269.    public void invalidate() {
  270.       this.valid = false;
  271.       if (this.parent != null && this.parent.valid) {
  272.          this.parent.invalidate();
  273.       }
  274.  
  275.    }
  276.  
  277.    public Graphics getGraphics() {
  278.       ComponentPeer var1 = this.peer;
  279.       return var1 != null ? var1.getGraphics() : null;
  280.    }
  281.  
  282.    public FontMetrics getFontMetrics(Font var1) {
  283.       ComponentPeer var2 = this.peer;
  284.       return var2 != null ? var2.getFontMetrics(var1) : this.getToolkit().getFontMetrics(var1);
  285.    }
  286.  
  287.    public void paint(Graphics var1) {
  288.    }
  289.  
  290.    public void update(Graphics var1) {
  291.       var1.setColor(this.getBackground());
  292.       var1.fillRect(0, 0, this.width, this.height);
  293.       var1.setColor(this.getForeground());
  294.       this.paint(var1);
  295.    }
  296.  
  297.    public void paintAll(Graphics var1) {
  298.       ComponentPeer var2 = this.peer;
  299.       if (this.visible && var2 != null) {
  300.          this.validate();
  301.          var2.paint(var1);
  302.       }
  303.  
  304.    }
  305.  
  306.    public void repaint() {
  307.       this.repaint(0L, 0, 0, this.width, this.height);
  308.    }
  309.  
  310.    public void repaint(long var1) {
  311.       this.repaint(var1, 0, 0, this.width, this.height);
  312.    }
  313.  
  314.    public void repaint(int var1, int var2, int var3, int var4) {
  315.       this.repaint(0L, var1, var2, var3, var4);
  316.    }
  317.  
  318.    public void repaint(long var1, int var3, int var4, int var5, int var6) {
  319.       ComponentPeer var7 = this.peer;
  320.       if (var7 != null && var5 > 0 && var6 > 0) {
  321.          var7.repaint(var1, var3, var4, var5, var6);
  322.       }
  323.  
  324.    }
  325.  
  326.    public void print(Graphics var1) {
  327.       this.paint(var1);
  328.    }
  329.  
  330.    public void printAll(Graphics var1) {
  331.       ComponentPeer var2 = this.peer;
  332.       if (this.visible && var2 != null) {
  333.          this.validate();
  334.          var2.print(var1);
  335.       }
  336.  
  337.    }
  338.  
  339.    public boolean imageUpdate(Image var1, int var2, int var3, int var4, int var5, int var6) {
  340.       int var7 = -1;
  341.       if ((var2 & 48) != 0) {
  342.          var7 = 0;
  343.       } else if ((var2 & 8) != 0) {
  344.          String var8 = System.getProperty("awt.image.incrementaldraw");
  345.          if (var8 == null || var8.equals("true")) {
  346.             String var9 = System.getProperty("awt.image.redrawrate");
  347.  
  348.             try {
  349.                var7 = var9 != null ? Integer.parseInt(var9) : 100;
  350.                if (var7 < 0) {
  351.                   var7 = 0;
  352.                }
  353.             } catch (Exception var10) {
  354.                var7 = 100;
  355.             }
  356.          }
  357.       }
  358.  
  359.       if (var7 >= 0) {
  360.          this.repaint((long)var7, 0, 0, this.width, this.height);
  361.       }
  362.  
  363.       return (var2 & 160) == 0;
  364.    }
  365.  
  366.    public Image createImage(ImageProducer var1) {
  367.       ComponentPeer var2 = this.peer;
  368.       return var2 != null ? var2.createImage(var1) : this.getToolkit().createImage(var1);
  369.    }
  370.  
  371.    public Image createImage(int var1, int var2) {
  372.       ComponentPeer var3 = this.peer;
  373.       return var3 != null ? var3.createImage(var1, var2) : null;
  374.    }
  375.  
  376.    public boolean prepareImage(Image var1, ImageObserver var2) {
  377.       return this.prepareImage(var1, -1, -1, var2);
  378.    }
  379.  
  380.    public boolean prepareImage(Image var1, int var2, int var3, ImageObserver var4) {
  381.       ComponentPeer var5 = this.peer;
  382.       return var5 != null ? var5.prepareImage(var1, var2, var3, var4) : this.getToolkit().prepareImage(var1, var2, var3, var4);
  383.    }
  384.  
  385.    public int checkImage(Image var1, ImageObserver var2) {
  386.       return this.checkImage(var1, -1, -1, var2);
  387.    }
  388.  
  389.    public int checkImage(Image var1, int var2, int var3, ImageObserver var4) {
  390.       ComponentPeer var5 = this.peer;
  391.       return var5 != null ? var5.checkImage(var1, var2, var3, var4) : this.getToolkit().checkImage(var1, var2, var3, var4);
  392.    }
  393.  
  394.    public synchronized boolean inside(int var1, int var2) {
  395.       return var1 >= 0 && var1 < this.width && var2 >= 0 && var2 < this.height;
  396.    }
  397.  
  398.    public Component locate(int var1, int var2) {
  399.       return this.inside(var1, var2) ? this : null;
  400.    }
  401.  
  402.    public void deliverEvent(Event var1) {
  403.       this.postEvent(var1);
  404.    }
  405.  
  406.    public boolean postEvent(Event var1) {
  407.       ComponentPeer var2 = this.peer;
  408.       if (this.handleEvent(var1)) {
  409.          return true;
  410.       } else {
  411.          Container var3 = this.parent;
  412.          if (var3 != null) {
  413.             var1.translate(this.field_0, this.field_1);
  414.             if (((Component)var3).postEvent(var1)) {
  415.                return true;
  416.             }
  417.          }
  418.  
  419.          return var2 != null ? var2.handleEvent(var1) : false;
  420.       }
  421.    }
  422.  
  423.    public boolean handleEvent(Event var1) {
  424.       switch (var1.id) {
  425.          case 401:
  426.          case 403:
  427.             return this.keyDown(var1, var1.key);
  428.          case 402:
  429.          case 404:
  430.             return this.keyUp(var1, var1.key);
  431.          case 501:
  432.             return this.mouseDown(var1, var1.x, var1.y);
  433.          case 502:
  434.             return this.mouseUp(var1, var1.x, var1.y);
  435.          case 503:
  436.             return this.mouseMove(var1, var1.x, var1.y);
  437.          case 504:
  438.             return this.mouseEnter(var1, var1.x, var1.y);
  439.          case 505:
  440.             return this.mouseExit(var1, var1.x, var1.y);
  441.          case 506:
  442.             return this.mouseDrag(var1, var1.x, var1.y);
  443.          case 1001:
  444.             return this.action(var1, var1.arg);
  445.          case 1004:
  446.             return this.gotFocus(var1, var1.arg);
  447.          case 1005:
  448.             return this.lostFocus(var1, var1.arg);
  449.          default:
  450.             return false;
  451.       }
  452.    }
  453.  
  454.    public boolean mouseDown(Event var1, int var2, int var3) {
  455.       return false;
  456.    }
  457.  
  458.    public boolean mouseDrag(Event var1, int var2, int var3) {
  459.       return false;
  460.    }
  461.  
  462.    public boolean mouseUp(Event var1, int var2, int var3) {
  463.       return false;
  464.    }
  465.  
  466.    public boolean mouseMove(Event var1, int var2, int var3) {
  467.       return false;
  468.    }
  469.  
  470.    public boolean mouseEnter(Event var1, int var2, int var3) {
  471.       return false;
  472.    }
  473.  
  474.    public boolean mouseExit(Event var1, int var2, int var3) {
  475.       return false;
  476.    }
  477.  
  478.    public boolean keyDown(Event var1, int var2) {
  479.       return false;
  480.    }
  481.  
  482.    public boolean keyUp(Event var1, int var2) {
  483.       return false;
  484.    }
  485.  
  486.    public boolean action(Event var1, Object var2) {
  487.       return false;
  488.    }
  489.  
  490.    public void addNotify() {
  491.       this.valid = false;
  492.    }
  493.  
  494.    public synchronized void removeNotify() {
  495.       if (this.peer != null) {
  496.          this.peer.dispose();
  497.          this.peer = null;
  498.       }
  499.  
  500.    }
  501.  
  502.    public boolean gotFocus(Event var1, Object var2) {
  503.       return false;
  504.    }
  505.  
  506.    public boolean lostFocus(Event var1, Object var2) {
  507.       return false;
  508.    }
  509.  
  510.    public void requestFocus() {
  511.       ComponentPeer var1 = this.peer;
  512.       if (var1 != null) {
  513.          var1.requestFocus();
  514.       }
  515.  
  516.    }
  517.  
  518.    public void nextFocus() {
  519.       ComponentPeer var1 = this.peer;
  520.       if (var1 != null) {
  521.          var1.nextFocus();
  522.       }
  523.  
  524.    }
  525.  
  526.    protected String paramString() {
  527.       String var1 = this.field_0 + "," + this.field_1 + "," + this.width + "x" + this.height;
  528.       if (!this.valid) {
  529.          var1 = var1 + ",invalid";
  530.       }
  531.  
  532.       if (!this.visible) {
  533.          var1 = var1 + ",hidden";
  534.       }
  535.  
  536.       if (!this.enabled) {
  537.          var1 = var1 + ",disabled";
  538.       }
  539.  
  540.       return var1;
  541.    }
  542.  
  543.    public String toString() {
  544.       return this.getClass().getName() + "[" + this.paramString() + "]";
  545.    }
  546.  
  547.    public void list() {
  548.       this.list(System.out, 0);
  549.    }
  550.  
  551.    public void list(PrintStream var1) {
  552.       this.list(var1, 0);
  553.    }
  554.  
  555.    public void list(PrintStream var1, int var2) {
  556.       for(int var3 = 0; var3 < var2; ++var3) {
  557.          var1.print("  ");
  558.       }
  559.  
  560.       var1.println(this);
  561.    }
  562. }
  563.